package com.itheima.rabbitmq.listener;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author : [chenxys]
 * @version : [v1.0]
 * @Description : 消息监听处理类
 * @createTime : [2022/6/24 13:22]
 */
@Component
public class MyListener {

    /**
     * 监听某个队列的消息
     * @author chenxys
     * @param message 接收到的消息
     * RabbitListener(queues = "队列名称")
     */
    @RabbitListener(queues = "boot_queue")
    public void myListener(String message){
        System.out.println("消费者接收到的消息为:"+message);
    }

    @RabbitListener(queues = "boot_queue")
    public void myListener(Message message){
        System.out.println("消费者接收到的消息为:"+ (new String(message.getBody())));
    }
}
